package bizlogic;

import dao.DAOException;
import dao.DAOFactory;
import dao.PriorityDAO;
import model.PriorityDTO;
import java.util.ArrayList;

public class PriorityManager {

	private PriorityDAO priDAO;
	
	public PriorityManager()
	{
		priDAO = DAOFactory.loadInstance().getPriorityDAO();
	}
	
	@SuppressWarnings("finally")
	public ArrayList<PriorityDTO> findAllPriority()
	{
		ArrayList<PriorityDTO> priAll = new ArrayList<PriorityDTO>();
		try{
			priAll = priDAO.findAllPriority();
		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		finally{
			return priAll;
		}	
	}
	
	@SuppressWarnings("finally")
	public PriorityDTO findPriority(int PriorityCode) 
	{
		PriorityDTO pri = new PriorityDTO();
		
		try
		{
			pri = priDAO.findPriority(PriorityCode);
		}catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		finally
		{
			return pri;
		}
	}
	
	public void insertPriority(PriorityDTO pri) {
    	try {
    		priDAO.insertPriority(pri);
		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    }
    public void updatePriority(PriorityDTO pri) {
    	try {
			priDAO.updatePriority(pri);
		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    }
    public void deletePriority(PriorityDTO pri) {
    	try {
			priDAO.deletePriority(pri);
		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    } 
}
